package c3p0Test;

import dao.StaffsDao;
import dao.impl.StaffDaoImpl4DbUtil;
import dao.impl.StaffsDaoImpl4jdbc;
import entity.Staffs;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author zqx
 * @Date 2024-03-08
 */
public class StaffDaoTest02 {
    /**
     * 测试分页查询
     */
    private static void testSelectByPage() {
        // 多态
        StaffsDao staffDao = new StaffDaoImpl4DbUtil();

        // 当前页
        int currentPage = 1;
        // 每页记录数
        int count = 2;

        int limit = (currentPage - 1) * count;

        List<Staffs> list = staffDao.selectAdPage(limit, count);

        // JDK8新语法
        list.stream().forEach(System.out::println);
    }

    /**
     * 测试修改操作
     */
    private static void testUpdate() {
        Staffs s = new Staffs();
        s.setName("张三三");
        s.setAge(28);
        s.setPos("项目经理");
        s.setPhone("13417747371");
        s.setUpdateTime(LocalDateTime.now());
        s.setId(1);

        StaffsDao staffDao = new StaffsDaoImpl4jdbc();
        int row = staffDao.update(s);
        System.out.println(row);
    }

    public static void main(String[] args) {
        testSelectByPage();
        //testUpdate();
    }
}
